src,test: handle EROFS in mkdir recursive#62725
Open
kennyhyun wants to merge 2 commits intonodejs:mainfrom
Open
src,test: handle EROFS in mkdir recursive#62725kennyhyun wants to merge 2 commits intonodejs:mainfrom
kennyhyun wants to merge 2 commits intonodejs:mainfrom
Conversation
mkdirSync with { recursive: true } on a read-only filesystem
incorrectly throws ENOENT instead of the expected EROFS error.
Two test cases are included:
- On Linux with passwordless sudo, mounts a real read-only tmpfs to
verify the error code against the actual kernel behavior.
- Uses internalBinding to mock binding.mkdir and simulate EROFS,
ensuring the error propagates correctly without requiring root.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mkdirSyncandmkdirpAsyncwith{ recursive: true }incorrectlyconvert
EROFS(read-only filesystem) toENOENTwhen the underlyingmkdirsyscall fails. This causes misleading errors when operating onread-only filesystems.
This PR adds
UV_EROFSto the list of errors that are returnedimmediately in
MKDirpSyncandMKDirpAsync, preventing the incorrectconversion.
Two test cases are included:
internalBindingto simulateEROFSwithoutrequiring elevated privileges.
tmpfsonLinux when passwordless
sudois available.Fixes: #47098
Refs: #48105
Co-authored-by: Alberto Moretti moretti919@gmail.com